package com.example.demo.thread;

public class MyThread {

    public static void main(String[] args) throws Exception {
        MyObject obj = new MyObject();


        new Thread(()-> {
            Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
            while(true) {

                obj.methodB();
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                }
            }

        }, "ThreadB").start();

        new Thread(()-> {
            Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
            while(true) {
                obj.methodA();

                try {
                    Thread.sleep(80);
                } catch (InterruptedException e) {

                }
            }
        }, "ThreadA").start();
    }
}
